package com.example.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.example.sentinel.sentinel.block.handler.DegradeBlockHandler;
import com.example.sentinel.service.SentinelService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 降级规则测试
 * @author chengjian 
 * @date 2021/7/2
 */
@RestController
public class DegradeController {

    @Resource
    private SentinelService sentinelService;

    @GetMapping(value = "/degrade")
    @SentinelResource(value = "test", blockHandlerClass = DegradeBlockHandler.class, blockHandler = "testBlockHandler")
    public String degrade(String uid) throws InterruptedException {
        return sentinelService.degrade(uid);
    }
}
